package com.dhj.optionalTest;

import com.dhj.streamTest.entity.Author;

import java.util.Optional;

public class Demo4 {

    public static void main(String[] args) {
        Author author = getAuthor();
        Optional<Author> optional = Optional.ofNullable(author);
        optional = optional.filter(author2 -> author.getAge() > 55);

        System.out.println(optional.get().getName());

        if(optional.isPresent()){
            System.out.println(optional.get().getName());
        }else{
            System.out.println("======== 不存在");
        }

    }


    public static Author getAuthor() {
        Author author = new Author(5L, "林则徐1", 65, "苟利国家生死以", null);
        return author;
    }


    public static Author getAuthor2() {
        return null;
    }

}
